using B.S.Data.ERP.API.Applications.DingDanCommands;
using ERP.Domain;
using ERP.infratrctrue;
using ERP.Requst;
using MediatR;
using SqlSugar;

namespace B.S.Data.ERP.API.Applications.DingDanHandlers
{
    public class QueryDingDanCommandHandler : IRequestHandler<QueryDingDanCommand, APIRequust<List<DingDan>>>
    {
        private readonly IBaseRepository<DingDan> _dingDanRepository;

        public QueryDingDanCommandHandler(IBaseRepository<DingDan> dingDanRepository)
        {
            _dingDanRepository = dingDanRepository;
        }

        public  Task<APIRequust<List<DingDan>>> Handle(QueryDingDanCommand request, CancellationToken cancellationToken)
        {
            var query = _dingDanRepository.GetAll().Where(x=>x.IsDele==false);
            return Task.FromResult(new APIRequust<List<DingDan>>
            {
                Data = query.ToList(),
                Msg = RequstCode.成功.ToString(),
                Code=RequstCode.成功
            });


        }
    }
}